package user.controller;

import common.util.Res;
import common.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import user.entity.User;
import user.service.UserService;

import java.util.List;

/**
 * @author Yang
 * @Date 2019/8/7 19:24
 */
@RestController
@RequestMapping("/Yang/User")
public class UserController {

    @Autowired
    private UserService userService;

    /***
     * @author Yang
     * @date 2019/8/7 19:29
     * @return : common.util.Result
     */
    @GetMapping("/findAll")
    public Result findAll(){
        List<User> userList = userService.findAll();
        return Res.makeOKRsp(userList);
    }

    /***
     * @author Yang
     * @date 2019/8/7 19:30
     * @param user :
     * @return : common.util.Result
     */
    @PostMapping("/update")
    public Result update(User user){
        int update = userService.update(user);
        return Res.makeOKRsp(update);
    }

    /***
     * @author Yang
     * @date 2019/8/7 19:32
     * @param id :
     * @return : common.util.Result
     */
    @GetMapping("/findById")
    public Result findById(String id){
        User byId = userService.findById(id);
        return Res.makeOKRsp(byId);
    }


}
